import { PageDateSelect } from '@/types/pages/enum';
import { MaterialStore, MaterialStoreList, WarnInfoList } from '@/types/pages/materialStore/interface';
import Mock from 'mockjs'
import { IDateLineChart, IDatePieChart } from '@/types/echart';

/** 期末期初 入库 出库 */
export const getMaterialStoreListData: (type: PageDateSelect, date?: Date) => Promise<MaterialStoreList> = function (type: PageDateSelect, date?: Date) {
    return new Promise((res, rej) => {

        let data: MaterialStoreList = {
            begin: { name: '初期库存', totalNum: Mock.mock('@integer(10000, 50000)'), unit: '万元', num: Mock.mock('@integer(10000, 50000)'), saleRate: '5%', 'upDownStatus': Mock.mock('@boolean') ,comparisonText:'比去年'},
            end: { name: '期末库存', totalNum: Mock.mock('@integer(10000, 50000)'), unit: '万元', num: Mock.mock('@integer(10000, 50000)'), saleRate: '5%', 'upDownStatus': Mock.mock('@boolean') ,comparisonText:'比去年'},
            in: { name: '入库', totalNum: Mock.mock('@integer(10000, 50000)'), unit: '万元', num: Mock.mock('@integer(10000, 50000)'), saleRate: '5%', 'upDownStatus': Mock.mock('@boolean') ,comparisonText:'比去年'},
            out: { name: '出库', totalNum: Mock.mock('@integer(10000, 50000)'), unit: '万元', num: Mock.mock('@integer(10000, 50000)'), saleRate: '5%', 'upDownStatus': Mock.mock('@boolean') ,comparisonText:'比去年'}
        }

        res(Mock.mock(data));
    })

}
/** 运输成本 */
export const getMaterialPieChart: (type: PageDateSelect, date?: Date) => Promise<Partial<IDatePieChart>> = function (type: PageDateSelect, date?: Date) {
    return new Promise((res, rej) => {
        const dataset: IDatePieChart = { title: '库存产品类别对比', dataset: { dimensions: ['名称', '类型'], 'source': [{ '名称': '榆林化学' + Mock.Random.cname(), '类型|1-100': 100, }, { '名称': '产品' + Mock.Random.cname(), '类型|1-100': 100, }, { '名称': '聚酯级' + Mock.Random.cname(), '类型|1-100': 100, }] } }
        res(Mock.mock(dataset));
    })

}
/** 获取煤炭 */
export const getCoalPieChart: (type: PageDateSelect, date?: Date) => Promise<Partial<IDatePieChart>> = function (type: PageDateSelect, date) {
    return new Promise((res, rej) => {
        const dataset: IDatePieChart = { title: '积压库存', dataset: { dimensions: ['名称', '类型'], 'source': [{ '名称': '产品' + Mock.Random.cname(), '类型|1-100': 100, }, { '名称': '产品' + Mock.Random.cname(), '类型|1-100': 100, }, { '名称': '聚酯级' + Mock.Random.cname(), '类型|1-100': 100, }] } }
        res(Mock.mock(dataset));
    })
}
/** 获取存货 */
// export const getInventoryLineChart: (type: PageDateSelect, date?: Date) => Promise<Partial<IDatePieChart>> = function (type: PageDateSelect, date) {
//     return new Promise((res, rej) => {
//         const dataset: IDatePieChart = { title: '收入类型占比', dataset: { dimensions: ['名称', '类型'], 'source': [{ '名称': '榆林化学' + Mock.Random.cname(), '类型|1-100': 100, }, { '名称': '产品' + Mock.Random.cname(), '类型|1-100': 100, }, { '名称': '聚酯级' + Mock.Random.cname(), '类型|1-100': 100, }] } }
//         res(Mock.mock(dataset));
//     })
// }
/** 库存趋势 */
export const getTendencyLineChart: (type: PageDateSelect, date?: Date) => Promise<Partial<IDateLineChart>> = function (type: PageDateSelect, date) {
    return new Promise((res, rej) => {
        const a = () => (Math.random() * 100).toFixed(2)
        const dataset: IDateLineChart = { title: '库存趋势', dataset: { dimensions: ['date', '实际', '预测'], source: [{ 'date': '2021-01-7', '实际': a(), '预测': a() }, { 'date': '2021-01-8', '实际': a(), '预测': a() }] } }
        res(Mock.mock(dataset));
    })
}

export const getWarnInfoList: (type: PageDateSelect, date?: Date) => Promise<WarnInfoList> = function (type: PageDateSelect, date) {
    return new Promise((res, rej) => {
        const datapie: IDatePieChart = { title: '聚脂乙二级', dataset: { dimensions: ['比例'], 'source': [{'比例|1-100': 100, }] } }
        const dataset: WarnInfoList = {
            one: { chart: datapie,overstockText:'积压库存',inventoryText:'库存现金', overstock: Mock.mock('@integer(5000, 15000)'), overstockUnit: '万吨', inventory: Mock.mock('@integer(5000, 15000)'), inventoryUnit: '万吨' },
            two: { chart: datapie,overstockText:'积压库存',inventoryText:'库存现金',  overstock: Mock.mock('@integer(5000, 15000)'), overstockUnit: '万吨', inventory: Mock.mock('@integer(5000, 15000)'), inventoryUnit: '万吨' },
            three: { chart: datapie,overstockText:'积压库存',inventoryText:'库存现金',  overstock: Mock.mock('@integer(5000, 15000)'), overstockUnit: '万吨', inventory: Mock.mock('@integer(5000, 15000)'), inventoryUnit: '万吨' },
        };

        res(Mock.mock(dataset));
    })
}




